home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / ge_cool.lha / GE_COOL2.1 / src / Tree / Base_Binary_Node.C < prev    next >
C/C++ Source or Header  |  1992-07-01  |  2KB  |  57 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12. // Created: MBN 07/18/89 -- Initial design and implementation
  13. // Updated: VDN 02/21/92 -- New lite version
  14. //
  15. // The CoolBinary_Node class implements  nodes for binary trees  that have  no data
  16. // slot.  This node class contains left and right subtree pointers.   Since the
  17. // CoolBinary_Node   class is  intended   for the  sole   use of  the parameterized
  18. // CoolBinary_Node<Type> class, all constructors and  methods are protected and the
  19. // CoolBinary_Tree class is declared as a friend class.
  20. //
  21. // The private data section contains two  pointers to CoolBinary_Node  objects, one
  22. // for the left subtree and one for the right subtree.  There are two protected
  23. // constructors  for the class.   The first takes  no arguments and initializes
  24. // the two pointers to  NULL.     The  second takes   a  reference  to  another
  25. // CoolBinary_Node object and duplicates its values.
  26. //
  27. // Methods are provided to determine if a node  is a  leaf or  the root of some
  28. // subtree and implement member-wise assignment from one CoolBinary_Node to another
  29. // via the overloaded operator=.
  30. //
  31.  
  32. #ifndef BASE_BINARY_NODEH            // If no definition for class
  33. #include <cool/Base_Binary_Node.h>        // include header file
  34. #endif    
  35.  
  36. // CoolBinary_Node -- Simple constructor to initialize a node object
  37. // Input:         None
  38. // Output:        None
  39.  
  40. CoolBinary_Node::CoolBinary_Node () {
  41.   this->ltree = NULL;                // Initialize left subtree
  42.   this->rtree = NULL;                // Initialize right subtree
  43.   this->avl_balance = 0;            // Initialize avl balance
  44. }
  45.  
  46. // ~CoolBinary_Node -- Destructor has to be virtual so that 
  47. //                     ~CoolBinary_Node<Type> is called on ltree and rtree.
  48. // Input:          None
  49. // Output:         None
  50.  
  51. CoolBinary_Node::~CoolBinary_Node () {
  52.   delete this->ltree;                // Delete left subtree, virtual
  53.   delete this->rtree;                // Delete right subtree
  54. }
  55.  
  56.  
  57.